<?php
/**
 * Dirox Framework
 * Copyright (C) 2005 - 2007 Dirox / Synexser
 * 
 * All rights reserved.
 */

//set include path to library folder and application folder
set_include_path('.' . PATH_SEPARATOR . './library/external/'.
				PATH_SEPARATOR . './application/'.
				PATH_SEPARATOR . './library/external/PEAR/'.
				PATH_SEPARATOR . './library/IO/'.
				PATH_SEPARATOR . './library/class/'. get_include_path());

//include constant config file (store config for DB, mail auto send...)
include("app_config.php");
include("app_constant.php");
include("app_common.php");
require("DRX.php");
require("DRX_Common.php");

//============================= DB_Object config =============================//
require_once("DRX_DataObject.php");
require_once("DRX_DataObject_Cast.php");

$options = &PEAR::getStaticProperty( 'DB_DataObject', 'options' );
$options = array(
	'schema_location'  				 => 'application/model',
	'class_location'   				 => 'application/model',
	'require_prefix'                 => 'model',
	'class_prefix'                   => 'DataObjects_',
);
$options = array_merge($options, $database_dsn);
//=========================== End DB_Object config ===========================//

//============================== Smarty config ===============================//
$smarty = new DRX_Smarty();
$smarty->left_delimiter =  '<{';
$smarty->right_delimiter =  '}>';

$smarty->caching      = false;
$smarty->template_dir = TEMPLATE_DIR;
$smarty->compile_dir  = TEMPLATE_C_DIR;
DRX::register("smarty", $smarty);
//============================ End smarty config =============================//

//============================= i18n setup ===================================//
if (!defined(ACTIVATE_UTF8_SUPPORT))
{
	define ("ACTIVATE_UTF8_SUPPORT", true);
}

if (ACTIVATE_UTF8_SUPPORT)
{
	// We set utf8 as default charset to  be returned with the content
	// this can be overriden by header("ContentType...);
	ini_set("default_charset","utf8");
}

$smarty->assign("utf8_charset_meta",
	'<meta http-equiv="Content-Type" content="text/html; charset=utf-8">');
$smarty->assign("utf8_form_attribute",
	' accept-encoding="utf-8" ');
//============================= END i18n setup ===============================//

//========================== Session Handler config ==========================//
$session = new DRX_SessionHandler();
if (defined("SESSION_HANDLER_TYPE") && SESSION_HANDLER_TYPE === "DATABASE") {
	session_set_save_handler(array(&$session, "open"),
							 array(&$session, "close"),
							 array(&$session, "read"),
							 array(&$session, "write"),
							 array(&$session, "destroy"),
							 array(&$session, "gc"));
}
DRX::register("session", $session);
session_start();
header("Content-type: text/html; charset=utf-8");
//======================== End Session Handler config ========================//

//============================== Language config ==============================//
$language = new DRX_MultiLanguage();
if(isset($setlang) && $setlang!="") {
	$language->SetChangeLanguage($setlang);
	$current_lang = $setlang;
}
else {
	$current_lang = $language->GetLanguage();
}
if(empty($current_lang)) $current_lang="vi";
DRX::register("language", $language);
//============================== Language config ==============================//
require("DRX_Controller.php");
?>
